package com.sd.view;

import java.util.Vector;

import com.alex.books.BookMark;
import com.alex.books.Chapter;
import com.sd.activity.R;
import com.sd.view.ChapterAdpater.ViewHolder;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class BookMarkAdapter extends BaseAdapter {

	private Vector<BookMark> mBookMarks;
	private Context mContext;
	private LayoutInflater mLayoutInflater;

	public BookMarkAdapter(Context context, Vector<BookMark> bookMark) {
		mContext = context;
		mBookMarks = bookMark;
		mLayoutInflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mBookMarks.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mBookMarks.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder = null;

		if (convertView == null) {
			holder = new ViewHolder();
			convertView = mLayoutInflater.inflate(R.layout.bookmark_view, null);
			holder.bookName = (TextView) convertView.findViewById(R.id.bookname);
			holder.bookInfo = (TextView) convertView.findViewById(R.id.bookinfo);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		
		BookMark bookmark = mBookMarks.get(position);
		holder.bookName.setText(bookmark.mIntro);
		holder.bookInfo.setText(bookmark.mTime);
		return convertView;
	}

	class ViewHolder {
		/**
		 * 做法名字
		 */
		RelativeLayout book1;
		/**
		 * 做法介绍
		 */
		TextView bookName;
		/**
		 * 做法加价
		 */
		TextView bookInfo;
	}

}
